﻿package Interface
{	
	import Core.InterfacePage;
	import Core.Game;
	import Core.Page;
	
	import caurina.transitions.Tweener;

	import flash.display.MovieClip;	
	import flash.events.Event;		

	public class PageWelcome extends InterfacePage
	{
		private var FLogo:MovieClip;
		private var FMenu:StartMenu;
		private var FNextPage:Page;
		
		public function PageWelcome() 
		{
			FMenu = getChildByName('Menu') as StartMenu;
			FLogo = getChildByName('WelocmeLogo') as MovieClip;			
			FLogo.y = -height;
			Tweener.addTween(FLogo, {y:0, time:2, transition: "easeOutBounce"});
			FMenu.visible = false;
		}
		
		public function FillMenu():void
		{
			for(var i in FGame.Pages)
			{
				if(FGame.Pages[i].MenuName != '')
					FMenu.AddItem(FGame.Pages[i]);
			}
		}
		
		public function Hide(ANextPage:Page):void
		{
			FNextPage = ANextPage;
			Tweener.addTween(FLogo, {y:-height, time:1, transition: "easeInOutCubic", onComplete:LogoTweenComplete});
		}
		
		private function LogoTweenComplete():void
		{		
			FGame.CurrentPage = FNextPage;
			dispatchEvent(new Event(Event.COMPLETE));
		}
		
		public function ShowMenu():void
		{
			FMenu.visible = true;
		}
		
		override public function set GameCore(AGame:Game):void
		{
			super.GameCore = AGame;		
		}	
	}	
}
